/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ui;

import java.awt.Graphics;
import object.Piece;
import util.ImageUtil;

/**
 *
 * @author XiaoLong
 */
public class NextPanel extends javax.swing.JPanel {
    //下一个大方块对象

    private Piece nextPiece;
    private ImageUtil imageUtil;

    /**
     * Creates new form NextPanel
     */
    public NextPanel() {
        initComponents();
        imageUtil = ImageUtil.getInstance();
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        if (this.nextPiece != null) {
            int x = this.getWidth() / 2 - nextPiece.getnWidth() / 2;
            int y = this.getHeight() / 2 - nextPiece.getnHight() / 2;
            nextPiece.setSquaresXLocation(x);
            nextPiece.setSquaresYLocation(y);
            imageUtil.paintPiece(g, nextPiece);
            nextPiece.setSquaresXLocation(-x);
            nextPiece.setSquaresYLocation(-y);
        }
    }

    public Piece getNextPiece() {
        return nextPiece;
    }

    public void setNextPiece(Piece nextPiece) {
        this.nextPiece = nextPiece;
        this.repaint();
    }

    /**
     * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 1, true));
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setMaximumSize(new java.awt.Dimension(68, 68));
        setMinimumSize(new java.awt.Dimension(68, 68));
        setName(""); // NOI18N
        setPreferredSize(new java.awt.Dimension(68, 68));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 66, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 66, Short.MAX_VALUE)
        );

        getAccessibleContext().setAccessibleName("");
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
